#include "color.h"
#include "music.hpp"
#include "../lvgl/lvgl.h"

LV_FONT_DECLARE(myFont);

static lv_obj_t *setSidebar();
static void addSidebarElement(lv_obj_t *sidebar);
lv_obj_t *localMusicLabel;

void startUI()
{
    addSidebarElement(setSidebar());
    music_ui->build();
}

// 创建左侧侧边栏
static lv_obj_t *setSidebar()
{
    auto *sidebar = lv_obj_create(lv_scr_act());
    lv_obj_remove_style_all(sidebar);
    lv_obj_set_style_bg_color(sidebar, lv_color_hex(LIGHTGRAY), 0);
    lv_obj_set_style_bg_opa(sidebar, LV_OPA_COVER, 0);
    lv_obj_set_size(sidebar, lv_pct(15), lv_pct(100));
    lv_obj_align(sidebar, LV_ALIGN_LEFT_MID, 0, 0);
    lv_obj_set_flex_flow(sidebar, LV_FLEX_FLOW_COLUMN);
    lv_obj_set_flex_align(sidebar, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
    return sidebar;
}

// 设置左侧侧边栏的元素
static void addSidebarElement(lv_obj_t *sidebar)
{
    // 显示音乐数量
    localMusicLabel = lv_label_create(sidebar);
    lv_obj_set_style_margin_top(localMusicLabel, 20, 0);
    lv_obj_set_style_text_font(localMusicLabel, &myFont, 0);
    lv_label_set_text(localMusicLabel, "本地音乐");
}
